const basePage = "/pages/home/index"

// 页面白名单
const whiteList = [
  '/pages/home/index',//首页
  '/pages/interlude/index',//过场动画
  '/pages/pay/index',//支付页
  '/pages/payResult/result',//测算结果页
  '/pages/payResult/otherPay',//其他支付页
  '/pages/payResult/report',//报告页
  '/pages/hehun/index',//合婚结果页
]

// 检查地址白名单
function checkWhite(url) {
  const path = url.split('?')[0]
  return whiteList.includes(path)
}

// 页面跳转验证拦截器 ||addInterceptor
let list = ["navigateTo", "redirectTo", "reLaunch", "switchTab"]
list.forEach(item => {
  uni.addInterceptor(item, {
    invoke(to) {
      if (checkWhite(to.url)) {
        return true
      }
      uni.reLaunch({ url: basePage })
      return false
    },
    fail(err) {
      console.log(err)
    }
  })
})
